﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinFormCenter.common {
    internal struct R<T> {
        public int Code { set; get; }
        public string Msg { set; get; }
        public T? Data { set; get; }


        public static R<T> Ok() => Get(0, "Ok");
        public static R<T> Ok(string msg) => Get(0, msg);
        public static R<T> Ok(T data) => Get(0, "Ok",data);
        public static R<T> Error(int code,string msg) => Get(code, msg);
        private static R<T> Get(int code, string msg, T data) => new() {
            Code = code,
            Msg = msg,
            Data = data
        };
        private static R<T> Get(int code, string msg) => new() {
            Code = code,
            Msg = msg
        };

    }

}
